package main

import (
	"fmt"
)

func main() {
	mapTest()
	//ch := make(chan int)
	//go pr(ch)
	//cu(ch)

	//sliceTest()
}

func mapTest() {
	m := map[int]int{1: 2, 3: 4}
	fmt.Println(m)
}

func sliceTest() {
	s := []int{1, 2, 3, 4}
	for key, val := range s {
		fmt.Println("key=", key)
		fmt.Println("val=", val)
	}
	s = append(s, 11)
	fmt.Println("s=", s)
}

func pr(in chan int) {
	for i := 0; i < 10; i++ {
		//fmt.Println("此时开始写")
		in <- i
	}
	close(in)
}

func cu(out chan int) {
	for val := range out {
		fmt.Println("i=", val)
	}
}
func sender(ch chan string, p *int) {
	ch <- "malongshuai"
	fmt.Println("p=", *p)
	*p++
	ch <- "gaoxiaofang"
	fmt.Println("p=", *p)
	*p++
	ch <- "wugui"
	fmt.Println("p=", *p)
	*p++
	ch <- "tuner"
	fmt.Println("p=", *p)
	*p++
}

func recver(ch chan string, p *int) {
	var recv string
	recv = <-ch
	fmt.Println(recv)
	//for {
	//	*p++
	//fmt.Println("p=", *p)
	//}
}
